package model;

import java.util.Observable;

class ControlUnit {
		
	private final int clockTime = 2000; //milliseconds
	private Observable fuObservable = new Observable();
	private Observable pipeObservable = new Observable();
	
	public void addObserver(FunctionalUnit fu){
		fuObservable.addObserver(fu);
	}
	
	public void addObserver(Pipe pipe){
		pipeObservable.addObserver(pipe);
	}
	
	public void notifyFU(String s){
		fuObservable.hasChanged();
		fuObservable.notifyObservers(s);
	}
	
	public void notifyPipe(){
		pipeObservable.hasChanged();
		pipeObservable.notifyObservers();
	}
	
	public void start(){
		notifyFU("GET");
		notifyFU("SET");
		notifyPipe();
		try {
			this.wait(clockTime,  0);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
